package com.tiemei.demo.unittest.mockito;

import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;

import java.util.List;

import org.junit.Test;
/**
 *  使用 doThrow()|doAnswer()|doNothing()|doReturn() 来 stub void方法
 *
 * @author tiemei.jdk
 * @date   2012-10-15
 */
public class StubVoidMethod {
	@Test(expected = RuntimeException.class)
	public void test () {
		// 1. mock
		List mockedList = mock(List.class);
		doThrow(new RuntimeException()).when(mockedList).clear(); 
		
		// 2. run
		mockedList.clear();  
	}
}
